#pragma once

#include "SDL_image.h"
#include "Resource.h"
#include "ResourceManager.h"
#include "Prism_Errors.h"

class SurfaceResource : public Resource
{
private:
	// The surface itself
	SDL_Surface* m_surface;

public:
	SurfaceResource():m_surface(NULL){}
	SurfaceResource(const std::string& path):m_surface(NULL)
	{
		LoadFromFile(path);
	}
	~SurfaceResource() { SDL_FreeSurface(m_surface); }

	int LoadFromFile(const std::string& path)
	{
		if(m_surface != NULL) SDL_FreeSurface(m_surface);

		m_surface = IMG_Load(path.c_str());

		if(m_surface == NULL) return ERR_SURF_NOT_LOADED;

		return m_id;

	}
};